$().ready(function() {
	validateRule();
});

$.validator.setDefaults({
	submitHandler : function() {
        setIntroduce()
		update();
	}
});
function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url : ctx+"/merchant/merchant/update",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules : {
            productIdent : {
                required : true
            },
            merchantName : {
                required : true
            },
            linkman : {
                required : true
            },
            tel : {
                required : true
            },
            merchantAddress : {
                required : true
            },
            bigCodeConfig : {
                required : true
            },
            smallCodeConfig : {
                required : true
            },
            codeConfig : {
                required : true
            }

        },
        messages : {
            productIdent : {
                required : icon + "请输入产品标识"
            },
            merchantName : {
                required : icon + "请输入商户名称"
            },
            linkman : {
                required : icon + "请输入联系人"
            },
            tel : {
                required : icon + "请输入电话"
            },
            merchantAddress : {
                required : icon + "请输入公司地址"
            },
            bigCodeConfig : {
                required : icon + "请输入大码匹配规则"
            },
            smallCodeConfig : {
                required : icon + "请输入小码匹配规则"
            },
            codeConfig : {
                required : icon + "请输入产品码匹配规则"
            }
        }
    })
}